home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / fbm12s.lha / fbm2tiff.c < prev    next >
C/C++ Source or Header  |  1994-07-18  |  2KB  |  79 lines

  1. /*****************************************************************
  2.  * fbm2tiff.c: FBM Release 1.2 24-Mar-93 Michael Mauldin
  3.  *
  4.  * Copyright (C) 1993 by Michael Mauldin.  Permission is granted
  5.  * to use this file in whole or in part for any purpose, educational,
  6.  * recreational or commercial, provided that this copyright notice
  7.  * is retained unchanged.  This software is available to all free of
  8.  * charge by anonymous FTP and in the UUNET archives.
  9.  *
  10.  * fbm2tiff.c: 
  11.  *    Convert an FBM format image to TIFF format.  Uses Sam Leffler's
  12.  *    libtiff.a TIFF image library to write TIFF format.  See also,
  13.  *    tiff2fbm for the opposite conversion.
  14.  *
  15.  * USAGE
  16.  *    % fbm2tiff [-N -g<graybits>] output.tiff < input.fbm
  17.  *
  18.  * EDITLOG
  19.  *    LastEditDate = Wed Mar 24 13:05:46 EST 1993 - Michael Mauldin
  20.  *    LastFileName = /usr2/mlm/src/misc/fbm/fbm2tiff.c
  21.  *
  22.  * HISTORY
  23.  * 24-Mar-93  Michael Mauldin (mlm@cs.cmu.edu) Carnegie Mellon
  24.  *    Moved writing code to fltiff.c for release 1.2
  25.  *
  26.  * 25-Jun-90  Michael Mauldin (mlm@cs.cmu.edu) Carnegie Mellon
  27.  *    Package for Release 1.0
  28.  *
  29.  * 13-Jun-90  Michael Mauldin (mlm) at Carnegie-Mellon University
  30.  *    Created.
  31.  *****************************************************************/
  32.  
  33. # include <stdio.h>
  34. # include <ctype.h>
  35. # include "fbm.h"
  36.  
  37. # define USAGE \
  38.   "Usage: fbm2tiff [-N -g<graybits>] output.tiff < input.fbm"
  39.  
  40. /****************************************************************
  41.  * main
  42.  ****************************************************************/
  43.  
  44. #ifndef lint
  45. static char *fbmid =
  46. "$FBM fbm2tiff.c <1.2> 24-Mar-93  (C) 1993 by Michael Mauldin, source \
  47. code available free from MLM@CS.CMU.EDU and from UUNET archives$";
  48. #endif
  49.  
  50. main (argc, argv)
  51. char *argv[];
  52. { FBM image;
  53.   int graybit=0;
  54.  
  55.   /* Get the options */
  56.   while (--argc > 0 && (*++argv)[0] == '-')
  57.   { while (*++(*argv))
  58.     { switch (**argv)
  59.       { case 'N':    graybit = 2; break;
  60.     case 'g':    graybit = atoi (*argv+1); SKIPARG; break;
  61.     default:        fprintf (stderr, "%s\n", USAGE);
  62.                         exit (1);
  63.       }
  64.     }
  65.   }
  66.   
  67.   if (argc != 1)
  68.   { fprintf (stderr, "%s\n", USAGE); }
  69.  
  70.   image.cm = image.bm = (unsigned char *) NULL;
  71.  
  72.   /* Now read in an FBM image and write a TIFF format file */
  73.   if (read_bitmap (&image, (char *) NULL) &&
  74.       write_tiff (&image, argv[0], graybit))
  75.   { exit (0); }
  76.   else
  77.   { exit (1); }
  78. }
  79.